const PangoFontDescription *font;
StTextAlign align;
gdouble spacing;
+ gchar *font_features;
st_theme_node_get_foreground_color (theme_node, &color);
clutter_text_set_color (text, &color);
pango_attr_list_insert (attribs, letter_spacing);
}
+ font_features = st_theme_node_get_font_features (theme_node);
+ if (font_features)
+ {
+ pango_attr_list_insert (attribs, pango_attr_font_features_new (font_features));
+ g_free (font_features);
+ }
+
clutter_text_set_attributes (text, attribs);
if (attribs)
return node->font_desc;
}
+gchar *
+st_theme_node_get_font_features (StThemeNode *node)
+{
+ int i;
+
+ ensure_properties (node);
+
+ for (i = node->n_properties - 1; i >= 0; i--)
+ {
+ CRDeclaration *decl = node->properties[i];
+
+ if (strcmp (decl->property->stryng->str, "font-feature-settings") == 0)
+ {
+ CRTerm *term = decl->value;
+
+ if (!term->next && term->type == TERM_IDENT)
+ {
+ gchar *ident = term->content.str->stryng->str;
+
+ if (strcmp (ident, "inherit") == 0)
+ break;
+
+ if (strcmp (ident, "normal") == 0)
+ return NULL;
+ }
+
+ return (gchar *)cr_term_to_string (term);
+ }
+ }
+
+ return node->parent_node ? st_theme_node_get_font_features (node->parent_node) : NULL;
+}
+
/**
* st_theme_node_get_border_image:
* @node: a #StThemeNode
*/
const PangoFontDescription *st_theme_node_get_font (StThemeNode *node);
+gchar *st_theme_node_get_font_features (StThemeNode *node);
+
StBorderImage *st_theme_node_get_border_image (StThemeNode *node);
StShadow *st_theme_node_get_box_shadow (StThemeNode *node);
StShadow *st_theme_node_get_text_shadow (StThemeNode *node);
g_free (value);
}
+static void
+assert_font_features (StThemeNode *node,
+ const char *node_description,
+ const char *expected)
+{
+ char *value = st_theme_node_get_font_features (node);
+
+ if (g_strcmp0 (expected, value) != 0)
+ {
+ g_print ("%s: %s.font-feature-settings: expected: %s, got: %s\n",
+ test, node_description, expected, value);
+ fail = TRUE;
+ }
+
+ if (value)
+ g_free (value);
+}
+
static char *
text_decoration_to_string (StTextDecoration decoration)
{
assert_font (text3, "text3", "serif Bold Oblique Small-Caps 24px");
}
+static void
+test_font_features (void)
+{
+ test = "font_features";
+ /* group1 has font-feature-settings: "tnum" */
+ assert_font_features (group1, "group1", "\"tnum\"");
+ /* text2 should inherit from group1 */
+ assert_font_features (text2, "text2", "\"tnum\"");
+ /* group2 has font-feature-settings: "tnum", "zero" */
+ assert_font_features (group2, "group2", "\"tnum\", \"zero\"");
+ /* text3 should inherit from group2 using the inherit keyword */
+ assert_font_features (text3, "text3", "\"tnum\", \"zero\"");
+ /* text4 has font-feature-settings: normal */
+ assert_font_features (text4, "text4", NULL);
+}
+
static void
test_pseudo_class (void)
{
test_border ();
test_background ();
test_font ();
+ test_font_features ();
test_pseudo_class ();
test_inline_style ();
margin-left: 1in;
background: #ff0000 url('some-background.png');
+
+ font-feature-settings: "tnum";
}
#text1 {
#group2 {
font: italic 12px serif;
+ font-feature-settings: "tnum", "zero";
}
#text3 {
font-weight: bold;
font-style: oblique;
font-size: 200%;
+ font-feature-settings: "pnum";
+}
+
+#text4 {
+ font-feature-settings: normal;
}
ClutterTexture {
color: #ff0000;
}
+#group2 > #text3 {
+ font-feature-settings: inherit;
+}
+
#group2 {
background-image: url('other-background.png');
padding: 1px 2px 3px 4px;